import static java.lang.StrictMath.PI;
import static java.lang.StrictMath.abs;
import model.Game;
import model.Hockeyist;
import model.Move;
import model.Unit;
import model.World;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Constantine
 */
public class SlowAttack extends AbstractAttack {

    public SlowAttack(Hockeyist self, World world, Game game, Move move, long puckOwner, long first) {
        super(self, world, game, move, puckOwner, first);
    }

    @Override
    protected void firstTeammate() {
        moving.moveTo(new Point(30, coords.getXcoord(0.0d), coords.getYcoord(-Math.signum(puckY) * 1.0d)), puck);
    }

    @Override
    protected void puckOwner() {
        Unit nearOpp = getOpponents(self).get(0);
        if (moving.getSpeed(nearOpp) > 1.0d) { // если на меня побежали
            move.setTurn(self.getAngleTo(getUnitById(first)));
            return;
        }
        if (abs(selfY) < 0.8d) { // если я выше 0.8 по Y
            move.setTurn(self.getAngleTo(new Point(1, coords.getXcoord(0.5d), coords.getYcoord(Math.signum(selfY) * 0.85d))));
            move.setSpeedUp(0.2d);
            return;
        } else if (selfX > 0.1d) {
            if (world.getMyPlayer().getGoalCount() > world.getOpponentPlayer().getGoalCount()) {    // если я веду в счете, то просто стою
                move.setTurn(self.getAngleTo(getUnitById(first)));
                return;
            }
            if (selfX < 0.2d) {
                if (getUnitById(first).getAngleTo(self) < 5 * PI / 180) {
                    pass(getUnitById(first));
                } else {
                    move.setTurn(self.getAngleTo(getUnitById(first)));
                }
                return;
            }
            move.setTurn(self.getAngleTo(new Point(1, coords.getXcoord(-0.1d), coords.getYcoord(Math.signum(selfY) * 0.9d))));
            move.setSpeedUp(0.2d);
            return;
        } else {
            new DefaultAttack(self, world, game, move, puckOwner, first);
        }

    }

}
